<?php

class McCube_Template_Parser_Element_Command_Block
    extends McCube_Template_Parser_Element_Command_Abstract{

   public function execution(array $element){
        if(isset(McCube_Template::$blocks[$element['name']]))
            return McCube_Template::$blocks[$element['name']];

        return $element['content'];
        //return '!-[BLOCK ['.$element['name'].'] NOT FOUND !]-!';
   }

   public function buildStart(array $element){
       return parent::buildPhpTag('$this->_block('
            . '\''.$element['name'].'\''
            .',\''.addslashes($element['content'])
        .'\');', true);
    }

    public function set($element){
        $element['content'] = $this->_tplEngine->parseString($element['content']);

        McCube_Template::$blocks[$element['name']] = $element['content'];
        return true;
    }
}